package com.example.wechat.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.wechat.R;
import com.example.wechat.activity.MomentsActivity;
import com.example.wechat.activity.NewsActivity;
import com.example.wechat.activity.ScanActivity;
import com.example.wechat.activity.ShakeActivity;

public class DiscoverFragment extends Fragment {

    private LinearLayout layoutMoments;
    private LinearLayout layoutScan;
    private LinearLayout layoutShake;
    private LinearLayout layoutNews;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_discover, container, false);
        initViews(view);
        setupListeners();
        return view;
    }

    private void initViews(View view) {
        layoutMoments = view.findViewById(R.id.layout_moments);
        layoutScan = view.findViewById(R.id.layout_scan);
        layoutShake = view.findViewById(R.id.layout_shake);
        layoutNews = view.findViewById(R.id.layout_news);
    }

    private void setupListeners() {
        layoutMoments.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), MomentsActivity.class);
            startActivity(intent);
        });

        layoutScan.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), ScanActivity.class);
            startActivity(intent);
        });

        layoutShake.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), ShakeActivity.class);
            startActivity(intent);
        });

        layoutNews.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), NewsActivity.class);
            startActivity(intent);
        });
    }
} 